<template>
	<view>
		<index-assistant v-if="userType == '2'"></index-assistant>
		<index-player-new v-else></index-player-new>
	</view>
</template>

<script>
	import {
		storageUserType
	} from '../../global/config.js'
	export default {
		data() {
			return {
				userType: '1',	     //用户类型 1 - 普通用户 2 - 助教用户
				filterArea: '',
			}
		},
		onLoad() {
			this.userType = uni.getStorageSync(storageUserType)
			
			//获取位置
			uni.getLocation({
				success: (locationRes) => {
					let params = {
						longitude: locationRes.longitude,
						latitude: locationRes.latitude,
					}
					this.requestCenter.updateUserPosition(params).then(res => {
					
					}).catch(e => {
						
					})
				}
			});
			
		},
		// 从地图选点插件返回后，在页面的onShow生命周期函数中能够调用插件接口，取得选点结果对象
		onShow() {
			// #ifdef MP
			const citySelector = requirePlugin('citySelector')
			const selectedCity = citySelector.getCity(); // 选择城市后返回城市信息对象，若未选择返回null
			if(selectedCity){
				this.filterArea = selectedCity.fullname || ''
				console.log(this.filterArea);
			}
			// #endif
		},
		onUnload() {
			// #ifdef MP
			const citySelector = requirePlugin('citySelector')
			// 页面卸载时清空插件数据，防止再次进入页面，getCity返回的是上次的结果
			citySelector.clearCity();
			console.log('this.filterArea');
			// #endif
		},
		methods: {
			selectCityBack(){
				// #ifdef MP
				const key = 'K6UBZ-D3K3Z-35CXK-ZPV5Z-3BHGK-FVFH5'; // 使用在腾讯位置服务申请的key
				const referer = '云尚桌球'; // 调用插件的app的名称
				const hotCitys = '昆明'; // 用户自定义的的热门城市
				uni.navigateTo({
				  url: `plugin://citySelector/index?key=${key}&referer=${referer}`,
				})
				// #endif
			},
			
		}
	}
</script>

<style scoped lang="less">

</style>
